<?php

/*

  Action	$4

  +$2
  Look at the top 5 cards of your deck. Either discard all of them, or put them back on top of your deck in any order.

 */

class Navigator extends Card implements iAction, iKingdom, iSeaside {

    public function __construct() {
        parent::__construct("Navigator", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+$2",
            "Look at the top 5 cards of your deck. Either discard all of them, or put them back on top of your deck in any order.");
    }

    public function play(Game $game, $isRealCard) {
        $game->addMoney(2);
        ScreenDisplay::addScreenMessage($game, true, "get +2$", "gets +2$");


        $cards = $game->removeCardsFromDrawDeck(5);

        if (sizeof($cards) > 0) {

            $options = array(new Option(1, "Discard"), new Option(2, "Put back"));
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "You peek on " . niceReadableString($game, $cards) . " what would you like to do?");
            ScreenDisplay::addScreenMessage($game, true, "peek on " . niceprint($cards), "peeks on " . sizeof($cards) . " cards");

            $answer = $output[0];

            if ($answer == "Discard") {
                $game->discardTempDiscardCards($cards);
                ScreenDisplay::addScreenMessage($game, false, " and discard them", " and discards them");
            } else {

                $output = MySocket::GetUserReply($game, Input_Reorder, $cards, -1, -1, null, "Choose the order of the cards");
                ScreenDisplay::addScreenMessage($game, false, " and put ".  nicePrint($output)." back on your deck ", " and puts ".sizeof($output)." cards back on his deck");
                $output = array_reverse($output);
                foreach ($output as $p) {
                    $game->putCardOnTopOfDrawDeck($p);
                }
            }
        }
        $game->cardActionFinished();
        return true;
    }

}

?>